<?php

namespace App\Services;
use App\Models\SystemConfig;

class ConfigService
{
    //
    public function getConf($key)
    {
        $config = SystemConfig::where('name',$key)->first();
        if($config)
        {
            return $config;
        }
        else{
            return [];
        }
    }

   

    //视频金额配置
    public static function videoPriceConfig()
    {
        $conf = cache()->rememberForever('system_video_price',  function () {
            $data= SystemConfig::firstOrCreate(
                ['slug'=>'videoPrice'],
                [
                    'name'=>'视频金额',
                    'slug'=>'videoPrice',
                    'content'=>[
                        'min_price'=>'1.00',
                        'max_price'=>'5.00'
                    ],
                    'mark'=>'min_price:最低价,max_price:最高价'
                ]
            );
            return $data;
        });
        return $conf;
    }


    //扣量配置
    public static function deductConfig()
    {
        $conf = cache()->rememberForever('system_deduct',  function () {
            $data= SystemConfig::firstOrCreate(
                ['slug'=>'system_deduct'],
                [
                    'name'=>'默认扣量',
                    'slug'=>'system_deduct',
                    'content'=>[
                        'deduct'=>'10',
                    ],
                    'mark'=>'deduct:扣量,多少单扣1'
                ]
            );
            return $data;
        });
        return $conf;
    }
}
